package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.ActionMode.Callback;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.view.ViewCompat;
import o.ah$i;
import o.ah.g;
import o.by;

@RestrictTo({d.LIBRARY_GROUP})
public class ActionBarContainer extends FrameLayout {
    private boolean ʻ;
    private View ʼ;
    private View ʽ;
    public boolean ˊ;
    public Drawable ˋ;
    public Drawable ˎ;
    public boolean ˏ;
    public Drawable ॱ;
    private View ॱॱ;
    private int ᐝ;

    public ActionBarContainer(Context context) {
        this(context, null);
    }

    public ActionBarContainer(Context context, AttributeSet attributeSet) {
        boolean z = true;
        super(context, attributeSet);
        ViewCompat.ˏ(this, new by(this));
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, g.ˏ);
        this.ˋ = obtainStyledAttributes.getDrawable(g.ʽ);
        this.ˎ = obtainStyledAttributes.getDrawable(g.ˏॱ);
        this.ᐝ = obtainStyledAttributes.getDimensionPixelSize(g.ˋ, -1);
        if (getId() == ah$i.ˏˏ) {
            this.ˏ = true;
            this.ॱ = obtainStyledAttributes.getDrawable(g.ॱˊ);
        }
        obtainStyledAttributes.recycle();
        if (this.ˏ) {
            if (this.ॱ != null) {
                z = false;
            }
        } else if (!(this.ˋ == null && this.ˎ == null)) {
            z = false;
        }
        setWillNotDraw(z);
    }

    public void onFinishInflate() {
        super.onFinishInflate();
        this.ॱॱ = findViewById(ah$i.ˋ);
        this.ʽ = findViewById(ah$i.ᐝ);
    }

    public void setPrimaryBackground(Drawable drawable) {
        boolean z = true;
        if (this.ˋ != null) {
            this.ˋ.setCallback(null);
            unscheduleDrawable(this.ˋ);
        }
        this.ˋ = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.ॱॱ != null) {
                this.ˋ.setBounds(this.ॱॱ.getLeft(), this.ॱॱ.getTop(), this.ॱॱ.getRight(), this.ॱॱ.getBottom());
            }
        }
        if (this.ˏ) {
            if (this.ॱ != null) {
                z = false;
            }
        } else if (!(this.ˋ == null && this.ˎ == null)) {
            z = false;
        }
        setWillNotDraw(z);
        invalidate();
    }

    public void setStackedBackground(Drawable drawable) {
        boolean z = true;
        if (this.ˎ != null) {
            this.ˎ.setCallback(null);
            unscheduleDrawable(this.ˎ);
        }
        this.ˎ = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.ˊ && this.ˎ != null) {
                this.ˎ.setBounds(this.ʼ.getLeft(), this.ʼ.getTop(), this.ʼ.getRight(), this.ʼ.getBottom());
            }
        }
        if (this.ˏ) {
            if (this.ॱ != null) {
                z = false;
            }
        } else if (!(this.ˋ == null && this.ˎ == null)) {
            z = false;
        }
        setWillNotDraw(z);
        invalidate();
    }

    public void setSplitBackground(Drawable drawable) {
        boolean z = true;
        if (this.ॱ != null) {
            this.ॱ.setCallback(null);
            unscheduleDrawable(this.ॱ);
        }
        this.ॱ = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.ˏ && this.ॱ != null) {
                this.ॱ.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            }
        }
        if (this.ˏ) {
            if (this.ॱ != null) {
                z = false;
            }
        } else if (!(this.ˋ == null && this.ˎ == null)) {
            z = false;
        }
        setWillNotDraw(z);
        invalidate();
    }

    public void setVisibility(int i) {
        boolean z;
        super.setVisibility(i);
        if (i == 0) {
            z = true;
        } else {
            z = false;
        }
        if (this.ˋ != null) {
            this.ˋ.setVisible(z, false);
        }
        if (this.ˎ != null) {
            this.ˎ.setVisible(z, false);
        }
        if (this.ॱ != null) {
            this.ॱ.setVisible(z, false);
        }
    }

    protected boolean verifyDrawable(Drawable drawable) {
        return (drawable == this.ˋ && !this.ˏ) || ((drawable == this.ˎ && this.ˊ) || ((drawable == this.ॱ && this.ˏ) || super.verifyDrawable(drawable)));
    }

    protected void drawableStateChanged() {
        super.drawableStateChanged();
        if (this.ˋ != null && this.ˋ.isStateful()) {
            this.ˋ.setState(getDrawableState());
        }
        if (this.ˎ != null && this.ˎ.isStateful()) {
            this.ˎ.setState(getDrawableState());
        }
        if (this.ॱ != null && this.ॱ.isStateful()) {
            this.ॱ.setState(getDrawableState());
        }
    }

    public void jumpDrawablesToCurrentState() {
        super.jumpDrawablesToCurrentState();
        if (this.ˋ != null) {
            this.ˋ.jumpToCurrentState();
        }
        if (this.ˎ != null) {
            this.ˎ.jumpToCurrentState();
        }
        if (this.ॱ != null) {
            this.ॱ.jumpToCurrentState();
        }
    }

    public void setTransitioning(boolean z) {
        this.ʻ = z;
        setDescendantFocusability(z ? 393216 : 262144);
    }

    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        return this.ʻ || super.onInterceptTouchEvent(motionEvent);
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        super.onTouchEvent(motionEvent);
        return true;
    }

    public boolean onHoverEvent(MotionEvent motionEvent) {
        super.onHoverEvent(motionEvent);
        return true;
    }

    public void setTabContainer(ScrollingTabContainerView scrollingTabContainerView) {
        if (this.ʼ != null) {
            removeView(this.ʼ);
        }
        this.ʼ = scrollingTabContainerView;
        if (scrollingTabContainerView != null) {
            addView(scrollingTabContainerView);
            LayoutParams layoutParams = scrollingTabContainerView.getLayoutParams();
            layoutParams.width = -1;
            layoutParams.height = -2;
            scrollingTabContainerView.setAllowCollapse(false);
        }
    }

    public View ˏ() {
        return this.ʼ;
    }

    public ActionMode startActionModeForChild(View view, Callback callback) {
        return null;
    }

    public ActionMode startActionModeForChild(View view, Callback callback, int i) {
        if (i != 0) {
            return super.startActionModeForChild(view, callback, i);
        }
        return null;
    }

    private boolean ˎ(View view) {
        return view == null || view.getVisibility() == 8 || view.getMeasuredHeight() == 0;
    }

    private int ˋ(View view) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
        return layoutParams.bottomMargin + (view.getMeasuredHeight() + layoutParams.topMargin);
    }

    public void onMeasure(int i, int i2) {
        if (this.ॱॱ == null && MeasureSpec.getMode(i2) == Integer.MIN_VALUE && this.ᐝ >= 0) {
            i2 = MeasureSpec.makeMeasureSpec(Math.min(this.ᐝ, MeasureSpec.getSize(i2)), Integer.MIN_VALUE);
        }
        super.onMeasure(i, i2);
        if (this.ॱॱ != null) {
            int mode = MeasureSpec.getMode(i2);
            if (this.ʼ != null && this.ʼ.getVisibility() != 8 && mode != 1073741824) {
                int ˋ;
                if (!ˎ(this.ॱॱ)) {
                    ˋ = ˋ(this.ॱॱ);
                } else if (ˎ(this.ʽ)) {
                    ˋ = 0;
                } else {
                    ˋ = ˋ(this.ʽ);
                }
                setMeasuredDimension(getMeasuredWidth(), Math.min(ˋ + ˋ(this.ʼ), mode == Integer.MIN_VALUE ? MeasureSpec.getSize(i2) : ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED));
            }
        }
    }

    public void onLayout(boolean z, int i, int i2, int i3, int i4) {
        int i5 = 1;
        super.onLayout(z, i, i2, i3, i4);
        View view = this.ʼ;
        boolean z2 = (view == null || view.getVisibility() == 8) ? false : true;
        if (!(view == null || view.getVisibility() == 8)) {
            int measuredHeight = getMeasuredHeight();
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
            view.layout(i, (measuredHeight - view.getMeasuredHeight()) - layoutParams.bottomMargin, i3, measuredHeight - layoutParams.bottomMargin);
        }
        if (!this.ˏ) {
            int i6;
            if (this.ˋ != null) {
                if (this.ॱॱ.getVisibility() == 0) {
                    this.ˋ.setBounds(this.ॱॱ.getLeft(), this.ॱॱ.getTop(), this.ॱॱ.getRight(), this.ॱॱ.getBottom());
                } else if (this.ʽ == null || this.ʽ.getVisibility() != 0) {
                    this.ˋ.setBounds(0, 0, 0, 0);
                } else {
                    this.ˋ.setBounds(this.ʽ.getLeft(), this.ʽ.getTop(), this.ʽ.getRight(), this.ʽ.getBottom());
                }
                i6 = 1;
            } else {
                i6 = 0;
            }
            this.ˊ = z2;
            if (!z2 || this.ˎ == null) {
                i5 = i6;
            } else {
                this.ˎ.setBounds(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
            }
        } else if (this.ॱ != null) {
            this.ॱ.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
        } else {
            i5 = 0;
        }
        if (i5 != 0) {
            invalidate();
        }
    }
}
